#if !defined(STATS_H)
#define STATS_H

#include <stdint.h>
#include <netinet/in.h>

struct stats_results;

int init_stats(void);
int free_stats(void);

int inbound(struct timeval tv, struct in_addr laddr, struct in_addr raddr,
                uint16_t lport, uint16_t rport);
int outbound(struct timeval tv, struct in_addr laddr, struct in_addr raddr,
                uint16_t lport, uint16_t rport);
                
struct stats_results *get_flush_stats(void);
int free_results(struct stats_results *);

unsigned stats_count(struct stats_results *r, int percentile);
unsigned long stats_avg(struct stats_results *r, int percentile);
unsigned long stats_sum(struct stats_results *r, int percentile);
unsigned long stats_sqs(struct stats_results *r, int percentile);
unsigned long stats_min(struct stats_results *r, int percentile);
unsigned long stats_max(struct stats_results *r, int percentile);
unsigned long stats_med(struct stats_results *r, int percentile);
unsigned long stats_var(struct stats_results *r, int percentile);
unsigned long stats_std(struct stats_results *r, int percentile);
unsigned long
stats_delay_count(struct stats_results *results, int percentile);

#endif